<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['middleware'=>'config'],function(){
    Auth::routes();
    Route::post('/upload','Admin\\ImageController@upload')->name('image_upload');
}
);
Route::get('/','Web\\IndexController@index');
Route::group(['prefix'=>'wap'],function (){
    $namespace='Web\\';
    Route::get('/',$namespace.'IndexController@index');
    //栏目下的新闻
    Route::get('/page/{slug}',$namespace.'PostController@index')->name('wap.post-list');
    Route::get('/ajax-list',$namespace.'PostController@ajaxList')->name('wap.post-list-ajax');
    Route::get('/{id}/page',$namespace.'PostController@detail')->name('wap.post-index');

});
Route::group(['prefix'=>'app'],function (){
    $namespace='App\\';
    Route::get('/',$namespace.'IndexController@index');
    //栏目下的新闻
    Route::get('/page/{slug}',$namespace.'PostController@index')->name('app.post-list');
    Route::get('/ajax-list',$namespace.'PostController@ajaxList')->name('app.post-list-ajax');
    Route::get('/{id}/page',$namespace.'PostController@detail')->name('app.post-index');

});
Route::group(['prefix'=>'coopen'],function (){
    $namespace='Coopen\\';
    Route::get('/',$namespace.'IndexController@index');
    //栏目下的新闻
    Route::get('/page/{slug}',$namespace.'PostController@index')->name('coopen.post-list');
    Route::get('/ajax-list',$namespace.'PostController@ajaxList')->name('coopen.post-list-ajax');
    Route::get('/{id}/page',$namespace.'PostController@detail')->name('coopen.post-index');

});
//更换语言
Route::get('/change_language/{language}', 'IndexController@change');

Route::group(['prefix'=>'admin','middleware'=>'admin.auth'],function(){
    $namespace='Admin\\';
    //admin首页
    Route::get('/',$namespace.'IndexController@index');
    Route::get('/main',$namespace.'IndexController@main');



    //退出登陆
    Route::get('/logout',$namespace.'IndexController@logout')->name('admin.logout');
    //得到菜单
    Route::get('/menu',$namespace.'IndexController@menu')->name('admin.menu');
    //图片文件模块
    Route::group(['prefix'=>'image'],function() use($namespace){
        Route::post('/upload',$namespace.'ImageController@upload')->name('admin.image_upload');
        Route::post('/upload1',$namespace.'ImageController@upload1')->name('admin.image_upload1');
    });

    Route::group(['prefix'=>'setting'],function() use($namespace){
        Route::get('/',$namespace.'SettingController@index')->name('admin.setting')->middleware('permission:setting');
        Route::post('/store',$namespace.'SettingController@saveChange')->name('admin.setting-store')->middleware('permission:setting');
    });
    //user模块
    Route::group(['prefix'=>'user'],function() use($namespace){
        //修改密码
        Route::get('/modify_password',$namespace.'UserController@modify_password')->name('admin.modify_password')->middleware('permission:modify_password');
        //修改密码提交
        Route::post('/modify_password/post',$namespace.'UserController@modify_password_post')->name('admin.password_post');
        //编辑用户信息
        Route::get('/{id}/edit',$namespace.'UserController@edit')->name('admin.user_edit')->middleware('permission:user_edit');

        Route::post('/update',$namespace.'UserController@update')->name('admin.user_update')->middleware('permission:user_edit');
        //查看用户信息
        Route::get('/{id}/detail',$namespace.'UserController@detail')->name('admin.user_detail')->middleware('permission:user_detail');
        //增加
        Route::get('/add',$namespace.'UserController@add')->name('admin.user_add')->middleware('permission:user_add');
        Route::post('/store',$namespace.'UserController@store')->name('admin.user_store')->middleware('permission:user_add');
        //屏蔽会员发布的所有作品
        Route::get('/{id}/display',$namespace.'UserController@display')->name('admin.user_display')->middleware('permission:user_display');
        //修改admin个人信息
        Route::get('/user_info',$namespace.'UserController@user_info')->name('admin.user_info');
        //提交修改个人信息
        Route::post('/user_info_post',$namespace.'UserController@user_info_post')->name('admin.user_info_post');
        //用户列表
        Route::get('/index',$namespace.'UserController@index')->name('admin.user_index');
        //设置前台权限
        Route::get('/{id}/set',$namespace.'UserController@user_set')->name('admin.user_set')->middleware('permission:user_set');
        //ajax获取用户数据
        Route::get('/ajax_user_list',$namespace.'UserController@ajax_list')->name('admin.user.ajaxList');

    });

//    //角色管理
    Route::group(['prefix'=>'role'],function() use($namespace){
        //列表页
        Route::get('/index',$namespace.'RoleController@index')->name('admin.role_index')->middleware('permission:role_index');
        //ajax获取
        Route::get('/ajax_list',$namespace.'RoleController@ajax_list')->name('admin.role_ajaxList')->middleware('permission:role_index');;
        //增加
        Route::get('/add',$namespace.'RoleController@create')->name('admin.role_add')->middleware('permission:role_add');
        Route::post('/store',$namespace.'RoleController@store')->name('admin.role_store')->middleware('permission:role_add');
        //授予权限
        Route::get('/{id}/permission',$namespace.'RoleController@permission')->name('admin.role_permission')->middleware('permission:role_permission');
        Route::post('/permission/store',$namespace.'RoleController@permissionStore')->name('admin.role_permission_store')->middleware('permission:role_permission');
        //修改
        Route::get('/{id}/edit',$namespace.'RoleController@edit')->name('admin.role_edit')->middleware('permission:role_edit');
        Route::post('/update',$namespace.'RoleController@update')->name('admin.role_update')->middleware('permission:role_edit');
        //删除
        Route::get('/del',$namespace.'RoleController@del')->name('admin.role_del')->middleware('permission:role_del');


    });
//    角色管理
//    Route::group(['prefix'=>'role'],function() use($namespace){
//        //列表页
//        Route::get('/index',$namespace.'RoleController@index')->name('admin.role_index');
//        //ajax获取
//        Route::get('/ajax_list',$namespace.'RoleController@ajax_list')->name('admin.role_ajaxList');
//        //增加
//        Route::get('/add',$namespace.'RoleController@create')->name('admin.role_add');
//        Route::post('/store',$namespace.'RoleController@store')->name('admin.role_store');
//        //授予权限
//        Route::get('/{id}/permission',$namespace.'RoleController@permission')->name('admin.role_permission');
//        Route::post('/permission/store',$namespace.'RoleController@permissionStore')->name('admin.role_permission_store');
//        //修改
//        Route::get('/{id}/edit',$namespace.'RoleController@edit')->name('admin.role_edit');
//        Route::post('/update',$namespace.'RoleController@update')->name('admin.role_update');
//        //删除
//        Route::get('/del',$namespace.'RoleController@del')->name('admin.role_del');
//
//
//    });
    //文章
    Route::group(['prefix'  =>  'posts'],function () use ($namespace){
        $namespace .= 'Posts\\';
        Route::get('',$namespace.'PostController@index')->name('admin.posts')->middleware('permission:posts');
        Route::get('/add',$namespace.'PostController@add')->name('admin.posts-add')->middleware('permission:posts');
        Route::post('/add',$namespace.'PostController@saveOrInsert')->middleware('permission:posts');
        Route::get('/edit/{id}',$namespace.'PostController@edit')->name('admin.posts-edit')->middleware('permission:posts');
        Route::post('/edit/{id}',$namespace.'PostController@saveOrInsert')->middleware('permission:posts');
        Route::get('/ajax',$namespace.'PostController@indexAjax')->name('admin.postsAjax')->middleware('permission:posts');
    });
    //广告位
    Route::group(['prefix'  =>  'adseat'],function ()use($namespace){
        $namespace .= 'Adseat\\';
        Route::get('',$namespace.'AdseatController@index')->name('admin.adseat')->middleware('permission:adseat');
        Route::get('/add',$namespace.'AdseatController@add')->name('admin.adseat-add')->middleware('permission:adseat');
        Route::post('/add',$namespace.'AdseatController@saveOrInsert')->middleware('permission:adseat');
        Route::get('/edit/{id}',$namespace.'AdseatController@edit')->name('admin.adseat-edit')->middleware('permission:adseat');
        Route::post('/edit/{id}',$namespace.'AdseatController@saveOrInsert')->middleware('permission:adseat');
        Route::get('/ajax',$namespace.'AdseatController@indexAjax')->name('admin.adseatAjax')->middleware('permission:adseat');
    });
    //郑州概况
    Route::group(['prefix'  =>  'area'],function ()use($namespace){
        $namespace .= 'Area\\';
        Route::get('',$namespace.'AreaController@index')->name('admin.area')->middleware('permission:posts');
        Route::get('/add',$namespace.'AreaController@add')->name('admin.area-add')->middleware('permission:posts');
        Route::post('/add',$namespace.'AreaController@saveOrInsert')->middleware('permission:posts');
        Route::get('/edit/{id}',$namespace.'AreaController@edit')->name('admin.area-edit')->middleware('permission:posts');
        Route::post('/edit/{id}',$namespace.'AreaController@saveOrInsert')->middleware('permission:adseat');
        Route::get('/ajax',$namespace.'AreaController@indexAjax')->name('admin.areaAjax')->middleware('permission:posts');
    });
    //栏目（暂时只有新闻动态）
    Route::group(['prefix'  =>  'categories'],function ()use($namespace){
        $namespace .= 'Category\\';
        Route::get('',$namespace.'CategoryController@index')->name('admin.category')->middleware('permission:posts');
        Route::get('/add',$namespace.'CategoryController@add')->name('admin.category-add')->middleware('permission:posts');
        Route::post('/add',$namespace.'CategoryController@saveOrInsert')->middleware('permission:posts');
        Route::get('/edit/{id}',$namespace.'CategoryController@edit')->name('admin.category-edit')->middleware('permission:posts');
        Route::post('/edit/{id}',$namespace.'CategoryController@saveOrInsert')->middleware('permission:posts');
        Route::get('/ajax',$namespace.'CategoryController@indexAjax')->name('admin.categoryAjax')->middleware('permission:posts');
    });
    //微信
    Route::group(['prefix'=>'wechat'],function() use ($namespace){
        $namespace .="Wechat\\";
        Route::group(['prefix'  =>  'material'],function ()use($namespace){
            $namespace .= 'Material\\';
            Route::get('',$namespace.'MaterialController@index')->name('admin.wechat.material')->middleware('permission:wx');
            Route::get('/add',$namespace.'MaterialController@add')->name('admin.wechat.material-add')->middleware('permission:wx');
            Route::post('/add',$namespace.'MaterialController@saveOrInsert')->middleware('permission:wx');
            Route::get('/edit/{id}',$namespace.'MaterialController@edit')->name('admin.wechat.material-edit')->middleware('permission:wx');
            Route::post('/edit/{id}',$namespace.'MaterialController@saveOrInsert')->middleware('permission:wx');
            Route::get('/ajax',$namespace.'MaterialController@indexAjax')->name('admin.wechat.materialAjax')->middleware('permission:wx');
        });
        Route::group(['prefix'  =>  'send'],function ()use($namespace){
            $namespace .= 'Send\\';
            Route::get('',$namespace.'IndexController@index')->name('admin.wechat.send')->middleware('permission:wx');
            Route::get('/add',$namespace.'IndexController@add')->name('admin.wechat.send-add')->middleware('permission:wx');
            Route::post('/add',$namespace.'IndexController@store')->middleware('permission:wx');
            Route::post('/edit/{id}',$namespace.'IndexController@saveOrInsert')->middleware('permission:wx');
            Route::get('/ajax',$namespace.'IndexController@indexAjax')->name('admin.wechat.sendAjax')->middleware('permission:wx');
            Route::get('/newsList',$namespace.'IndexController@newsList')->name('admin.wechat.send.newsList')->middleware('permission:wx');
            Route::get('/ajaxNewsList',$namespace.'IndexController@newsListAjax')->name('admin.wechat.send.newsListAjax')->middleware('permission:wx');

        });
    });
    Route::group(['prefix'=>'coopen'],function () use ($namespace){
        $namespace .="Coopen\\";
        Route::group(['prefix'=>'coopen'],function () use ($namespace){
            $namespace .='CoopenController@';
            Route::get('',$namespace.'index')->name('admin.coopen.coopen')->middleware('permission:wap');
            Route::post('',$namespace.'update')->name('admin.coopen.coopen.update')->middleware('permission:wap');
            Route::get('/videolist',$namespace.'videoList')->name('admin.coopen.coopen.videoList')->middleware('permission:wap');
        });
    });

});
//admin 登陆
Route::get('admin/login','Admin\LoginController@showLoginForm');
//登录表单提交
Route::post('admin/loginPost','Admin\LoginController@Login')->name('admin.login');

Route::get('/error','Admin\IndexController@error')->name('admin.error');

Route::any('/wx','Wx\IndexController@index')->name('wx');